package com.demo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.common.AjaxResult;
import com.demo.dto.LoginUserDTO;
import com.demo.entity.User;
import com.demo.service.UserService;
import com.demo.vo.UserVo;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * Author：汤小洋
 * Date：2025-10-10 15:48
 * Description：<描述>
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginUserDTO loginUserDTO){
        UserVo userVo = userService.login(loginUserDTO);
        return  AjaxResult.success(userVo);
    }

    @GetMapping("/page")
    public AjaxResult page(@RequestParam(defaultValue = "1") Integer pageNum,
                           @RequestParam(defaultValue = "10") Integer pageSize,
                           User user){
        Page<User> page = userService.findPage(pageNum, pageSize,user);
        return AjaxResult.success(page);
    }

}
